package br.com.projeto.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ProjetoUtils {
	
	public static String getDataFormatada(Date data, String format){
		SimpleDateFormat f = new SimpleDateFormat(format);
		if(data != null){
			return f.format(data);
		}else{
			return null;
		}
	}
	
	public static Date getDate(Date data, String format){
		try{
			if(data != null){
				SimpleDateFormat f = new SimpleDateFormat(format);
				data = f.parse(f.format(data));
			}else{
				return null;
			}
		}catch (Exception e) {
			System.out.println("Erro em ProjetoUtils.getDate"+e.getMessage());
		}
		return data;
	}
	
	public static String getData(Date data){
		SimpleDateFormat f = new SimpleDateFormat("yyyy");
		if(data != null){			
			return f.format(data)+"-01-01";
		}else{
			return null;
		}
	}
}
